using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;
public partial class Admin_TrangThaiDHList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack )
        {
            load_data();
        }
    }
    protected void lbt_Delete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in this.Repeater1.Items)
        {
            CheckBox chk = (CheckBox)item.FindControl("cb_xoa");
            if (chk.Checked == true)
            {
                HiddenField hf_id = (HiddenField)item.FindControl("hf_id");
                tbDiaDiemBUS.Detele(int.Parse(hf_id.Value));
            }
        }
        load_data();
    }
    private void load_data()
    {
        PagerV2_8_1.PageSize = 5;
        Criteria cri = new Criteria();
        int Total = 0;
        
        //PagerV2_8_1 .PageSize =int.Parse (ConfigurationManager.AppSettings ["pagesize"].ToString ());
        tbTrangThaiDHCollection  ttdhcolection = tbTrangThaiDHBUS.Get(cri.Criter, PagerV2_8_1.CurrentIndex,
                                                           PagerV2_8_1.PageSize, tbTrangThaiDHColumns .IdTrangThaiDH .ToString (),
                                                           OrderDirection.ASC.ToString(), out Total);
        Repeater1.DataSource = ttdhcolection;
        Repeater1.DataBind();
        PagerV2_8_1.ItemCount = Total;
        if (Total <= PagerV2_8_1.PageSize)
            PagerV2_8_1.Visible = false;
    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {

            Literal lit_TenTT = (Literal)e.Item.FindControl("lit_TenTT");
            Literal lit_MaTT = (Literal)e.Item.FindControl("lit_MaTT");
            
            tbTrangThaiDH ttdonhang = (tbTrangThaiDH)e.Item.DataItem;
            lit_MaTT.Text = ttdonhang.IdTrangThaiDH .ToString();

           
            lit_TenTT.Text = ttdonhang .TrangThai_DH .ToString ();

        }
    }
    protected void btn_Search_Click(object sender, EventArgs e)
    {
        load_data();
    }
    protected void pager_Command(object sender, CommandEventArgs e)
    {
        PagerV2_8_1.CurrentIndex = int.Parse(e.CommandArgument.ToString());
        load_data();
    }
}
